package ar.com.ford.it.fullEconomics.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import com.ford.it.properties.PropertyGroup;
import com.ford.it.properties.PropertyManager;

/**
 * ReConfigProvider <br>
 * Mantiene los seteos para que puedan ser accedidos desde cualquier parte de la aplicacion<br>
 * 
 * @author Aji <br>
 *
 */
public class ReConfigProvider {
    
    private static String appName;
    private static String appPath;
    private static HashMap incomingDirs;
    private static String smtpServer;
    private static String targetURL;
    private static String proxyServer;
    private static Integer proxyPort;
    private static String privKeyFile;
    private static String xmlBackupFileNamePrefix;
    private static String xmlBackupDirectory;
    private static String dirProcesados;    
    private static String dirRechazados;    
    private static String dirPoolFiles;
    

    /**
     * 
     * @param path
     * @param propMgr
     */
    public static void init(String path, PropertyManager propMgr) {
        
        PropertyGroup propGroup = propMgr.getChildGroup("RentasConfig");
        
        appName = "RE";
        appPath = path;
        
        incomingDirs = new HashMap();
        incomingDirs.put("VH", "INVH");
        incomingDirs.put("MK", "INMK");
        incomingDirs.put("PA", "INPA");
        incomingDirs.put("FD", "INFD");

        smtpServer = propGroup.getString("smtpServer");
        targetURL = propGroup.getString("url");
        
        
        proxyServer = propGroup.getString("proxy");
        if (proxyServer != null) 
            proxyPort = new Integer(propGroup.getInt("proxyPort"));
        
        privKeyFile = propGroup.getString("privKeyFile");
        xmlBackupFileNamePrefix = "XMLRENTAS";
        xmlBackupDirectory = "BKP";
        dirProcesados = "PROC";
        dirRechazados = "RECH";
        dirPoolFiles = "POOL";
    }


    /**
     * @return
     */
    public static ArrayList getSistemas() {
        return new ArrayList(Arrays.asList(incomingDirs.keySet().toArray()));
    }

    /**
     * 
     * @param sistema
     * @return
     */
    public static String getIncomingDir(String sistema) {
        return (String)incomingDirs.get(sistema);
    }


    /**
     * @return
     */
    public static String getSmtpServer() {
        return smtpServer;
    }

    /**
     * @return
     */
    public static String getAppPath() {
        return appPath;
    }

    /**
     * @return
     */
    public static String getTargetURL() {
        return targetURL;
    }

    /**
     * @return
     */
    public static Integer getProxyPort() {
        return proxyPort;
    }

    /**
     * @return
     */
    public static String getProxyServer() {
        return proxyServer;
    }

    /**
     * @return
     */
    public static String getDirProcesados() {
        return dirProcesados;
    }

    /**
     * @return
     */
    public static String getDirPoolFiles() {
        return dirPoolFiles;
    }

    /**
     * @return
     */
    public static String getPrivKeyFile() {
        return privKeyFile;
    }

    /**
     * @return
     */
    public static String getAppName() {
        return appName;
    }

    /**
     * @return
     */
    public static String getXmlBackupFileNamePrefix() {
        return xmlBackupFileNamePrefix;
    }

    /**
     * @return
     */
    public static String getXmlBackupDirectory() {
        return xmlBackupDirectory;
    }

    /**
     * @return
     */
    public static String getDirRechazados() {
        return dirRechazados;
    }


    

}
